package com.tencent.iov.cowin.befsale.clue.service.tenant.impl;

import com.google.common.collect.Lists;
import com.software.boot.common.entity.Response;
import com.tencent.iov.cowin.befsale.clue.dao.http.tenant.TenantClient;
import com.tencent.iov.cowin.befsale.clue.dao.http.tenant.request.QueryDictionariesRequest;
import com.tencent.iov.cowin.befsale.clue.dao.http.tenant.response.DictionariesResponse;
import com.tencent.iov.cowin.befsale.clue.service.tenant.DictionaryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Caychen
 * @Date: 2022/2/23 22:34
 * @Description:
 */
@Service
@Slf4j
public class DictionaryServiceImpl implements DictionaryService {

    @Autowired
    private TenantClient tenantClient;

    /**
     * 根据类型查询字典值集合
     *
     * @param intentionGradeType
     * @return
     */
    @Override
    public List<DictionariesResponse> listDictionary(String intentionGradeType) {
        QueryDictionariesRequest queryDictionariesRequest = new QueryDictionariesRequest();
        queryDictionariesRequest.setType(intentionGradeType);
        Response<List<DictionariesResponse>> dictionariesListByParam = tenantClient.getDictionariesListByParam(queryDictionariesRequest);
        return CollectionUtils.isNotEmpty(dictionariesListByParam.getData()) ? dictionariesListByParam.getData() : Lists.newArrayList();
    }
}
